﻿$(function() {
    autoResize({ dataGrid: '#Grid', callback: Initlist });

    $('#Add').window({
        iconCls: 'icon-add',
        zIndex: 1000,
        draggable: true,
        resizable: false,
        shadow: true,
        inline: true,
        modal: true,
        title: '添加合同委外信息',
        collapsible: false,
        minimizable: false,
        maximizable: false,
        closable: true,
        width: 450,
        height: 170,
        closed: true,
        onOpen: function() {
            $('#Add').parent().css("left", "25%");
            $('#Add').parent().next().css("left", "25%");
            $('#Add').parent().next().css("top", "25%");
            $('#Add').parent().css("top", "25%");
        }
    });
    $('#Add').show();
});

function Initlist(size) {
    $('#Grid').datagrid({
        tilte: '合同委外信息',
        iconCls: 'icon-save',
        width: size.width,
        height: size.height,
        pageSize: Math.round(size.height / 25),
        pageList: [Math.round(size.height / 25)],
        nowrap: true,
        striped: true,
        url: '../Project/Handler/ProjectInfo.ashx',
        sortName: 'Id',
        sortOrder: 'desc',
        idField: 'Id',
        frozenColumns: [[{ title: '编号', field: 'Id', width: 80, sortable: true}]],
        columns: [[
                            { title: '合同编号', field: 'ContractsInfoID.ContractsInternalNum', width: 80 },
                            { title: '合同名称', field: 'ContractsInfoID.ContractsName', width: 100 },
                            { title: '委外合同名称', field: 'ContractsName', width: 120 },
                            { title: '合同金额', field: 'ContractsAmount', width: 100 }
                            
                        ]],
        pagination: true,
        rownumbers: true,
        singleSelect: true,
        toolbar: [
                    {
                        text: '添加',
                        iconCls: 'icon-add',
                        handler: Add
                    }, '-',
                    {
                        text: '修改',
                        iconCls: 'icon-edit',
                        handler: Update
                    }, '-',
                    {
                        text: '删除',
                        iconCls: 'icon-remove',
                        handler: function() { }
                    }, '-',
                    {
                        text: '查询',
                        iconCls: 'icon-search',
                        handler: Search
                    }
                  ]
    });
}
function Add() {
    $('#Add').window({ title: '添加合同委外信息', iconCls: 'icon-add', closed: false });
}
function Update() {
    $('#Add').window({ title: '修改合同委外信息', iconCls: 'icon-edit', closed: false });
}
function Search() {
    $('#Add').window({ title: '查询合同委外信息', iconCls: 'icon-search', closed: false });
}